// require('es6-promise').polyfill()

import Vue from 'vue'

window.APIPATH = /^(.*\/\/[^\/]*\/).*$/.exec(window.location.href)[1]
Vue.prototype.$S = {
  // pathWs: process.env.NODE_ENV === 'development' ? 'http://192.168.200.27/' : window.APIPATH,
  pathWs: process.env.NODE_ENV === 'development' ? 'http://192.168.200.27/' : window.APIPATH,
  path: ''
}

Vue.prototype.$t = t => {
  return t
}
Vue.prototype.JSONs = t => {
  return JSON.parse(JSON.stringify(t))
}
Vue.prototype.JSONo = (t, b) => {
  return Object.assign({}, t, b)
}

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import '@/styles/index.scss' // global css

import App from './App'
import router from './router'
import store from './store'

import './icons' // icon
import './errorLog' // error log
import './permission' // permission control

import * as filters from './filters' // global filters

Vue.use(Element, {
  size: 'medium' // set element-ui default size
})

// register global utility filters.
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: {
    App
  }
})
